package site.wanjiahao;

import site.wanjiahao.file.file.FileInfo;
import site.wanjiahao.file.file.Files;
import site.wanjiahao.set.*;
import site.wanjiahao.util.Time;

public class Main {

    public static void main(String[] args) {
        test2();
    }

    static void test2() {

        FileInfo fileInfo = Files.read("D:\\study\\Java\\jdk\\jdk1.8\\src\\java\\util\\jar",
                new String[]{"java"});

        System.out.println("文件数量：" + fileInfo.getFiles());
        System.out.println("代码行数：" + fileInfo.getLines());
        String[] words = fileInfo.words();
        System.out.println("单词数量：" + words.length);

        Time.execute("list", () -> testSet(new ListSet<>(), words));

        Time.execute("optimize", () -> testSet(new ListOptimizeSet<>(), words));
    }

    static void testSet(Set<String> set, String[] words) {
        for (int i = 0; i < words.length; i++) {
            set.add(words[i]);
        }
       /* for (int i = 0; i < words.length; i++) {
            set.contains(words[i]);
        }
        for (int i = 0; i < words.length; i++) {
            set.remove(words[i]);
        }*/
    }

}
